<?php
$name=$_POST['user'];
$psw=$_POST['psw'];

$code=$_POST['code'];

session_start();
$code1=$_SESSION['verifyCode'];
if(!($code==$code1)){
    exit("<script>alert('验证码错误');location.href='login.php'</script>");
}


try{
    $dsn='mysql:host=localhost;dbname=yunbbs;charset=utf8';
    $pdo=new PDO($dsn,'root','123456',array(
       PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION 
    ));
} catch (PDOException $e){
    echo '数据库链接失败'.$e->getMessage().'<hr>';
}

$stmt=$pdo->prepare("select * from yunbbs_users where name=? and password=?");
$stmt->bindParam(1, $name);
$stmt->bindParam(2, $psw);
$stmt->execute();

if($stmt->rowCount()>0){
   exit("<script>alert('登录成功');location.href='loginSuccsee.php'</script>");
}else{
   exit("<script>alert('该用户不存在或密码错误请重新登录');location.href='login.php'</script>");
}


$pdo=null;





?>